﻿using Framework.SqlSugarCore.Abstractions;
using Framework.SqlSugarCore.Repositories;
using my.abp.Domain.Repositories.Role;
using my.abp.Domain.Shared.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;

namespace my.abp.SqlSugarCore.Repositories.Role
{
	public class SysRoleMenuRepository : SqlSugarRepository<SysRoleMenu>, ISysRoleMenuRepository, ITransientDependency
	{
		public SysRoleMenuRepository(ISugarDbContextProvider<ISqlSugarDbContext> sugarDbContextProvider) : base(sugarDbContextProvider)
		{
		}

		/// <summary>
		/// 根据角色Id集合获取菜单Id集合
		/// </summary>
		/// <param name="roleIdList"></param>
		/// <returns></returns>
		public async Task<List<long>> GetRoleMenuIdList(List<long> roleIdList)
		{
			return await _DbQueryable
				.Where(u => roleIdList.Contains(u.RoleId))
				.Select(u => u.MenuId).ToListAsync();
		}
	}
}
